package 高考志愿填报系统1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 创建学生对象
        System.out.println("请输入学生姓名：");
        String studentName = scanner.nextLine();
        Student student = new Student("001", studentName);

        // 创建大学对象并添加专业
        boolean finished = false;
        while (!finished) {
            System.out.println("请输入大学名称（输入'end'结束输入）：");
            String universityName = scanner.nextLine();
            if ("end".equals(universityName)) {
                finished = true;
                continue;
            }

            University university = new University(universityName, universityName);
            System.out.println("请输入专业名称（输入'end'结束输入）：");
            String majorName = scanner.nextLine();
            while (!majorName.equals("end")) {
                university.addMajor(new Major(majorName, majorName));
                System.out.println("请输入下一个专业名称（输入'end'结束输入）：");
                majorName = scanner.nextLine();
            }

            Volunteer volunteer = new Volunteer(university);
            student.addVolunteer(volunteer);
        }

        // 打印初始志愿列表
        System.out.println("初始志愿列表：");
        student.printVolunteers();
        // 调整志愿顺序
        System.out.println("请输入要调整的志愿序号：");
        int index = scanner.nextInt();
        scanner.nextLine(); // 消耗掉nextInt后的换行符
        System.out.println("请输入新的志愿序号：");
        int newIndex = scanner.nextInt();
        scanner.nextLine(); // 消耗掉nextInt后的换行符
        student.adjustVolunteerOrder(index, newIndex);

        // 打印调整后的志愿列表
        System.out.println("调整后的志愿列表：");
        student.printVolunteers();

        // 关闭扫描器
        scanner.close();
    }
}
